import axios from 'axios'

const http=axios.create({
    timeout:20000,
    baseURL:process.env.baseURL,

})

//请求拦截器
http.interceptors.request.use(
    config=>{
        console.log('请求的参数',config)
        return config
    },
    error=>{
        return Promise.reject(error)
    }
    
)

//响应拦截器
http.interceptors.response.use(
    response=>{
        console.log('返回的数据',response)
        const res= 'status' in response ? response.data :response
        return res
    },
    error=>{
        return Promise.reject(error)
    }
)

export default http